﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace EF
{
     public  class MyDbContext: DbContext
    {
        public MyDbContext() : base("name=sql1")
        {
            //base来读取连接字符串
        }
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            //一次性加载所有的映射关系(实体类跟表的映射)
            modelBuilder.Configurations.AddFromAssembly(Assembly.GetExecutingAssembly());
        }

        public DbSet<Student> Students { get; set; }
    }
}
